package com.ysqcould.web.controller.revita;


import com.ysqcould.common.annotation.Log;
import com.ysqcould.common.core.controller.BaseController;
import com.ysqcould.common.core.domain.AjaxResult;
import com.ysqcould.common.core.page.TableDataInfo;
import com.ysqcould.common.enums.BusinessType;
import com.ysqcould.common.utils.poi.ExcelUtil;
import com.ysqcould.revita.domain.GslNotice;
import com.ysqcould.revita.domain.GslSlideShow;
import com.ysqcould.revita.service.IGslSlideShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 乡村振兴轮播图Controller
 * 
 * @author ruoyi
 * @date 2022-06-30
 */
@RestController
@RequestMapping("/revita/show")
public class GslSlideShowController extends BaseController
{
    @Autowired
    private IGslSlideShowService gslSlideShowService;

    /**
     * 查询乡村振兴轮播图列表
     */
    @PreAuthorize("@ss.hasPermi('revita:show:list')")
    @GetMapping("/list")
    public TableDataInfo list(GslSlideShow gslSlideShow)
    {
        startPage();
        List<GslSlideShow> list = gslSlideShowService.selectGslSlideShowList(gslSlideShow);
        return getDataTable(list);
    }

    /**
     * 导出乡村振兴轮播图列表
     */
    @PreAuthorize("@ss.hasPermi('revita:show:export')")
    @Log(title = "乡村振兴轮播图", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GslSlideShow gslSlideShow)
    {
        List<GslSlideShow> list = gslSlideShowService.selectGslSlideShowList(gslSlideShow);
        ExcelUtil<GslSlideShow> util = new ExcelUtil<GslSlideShow>(GslSlideShow.class);
        util.exportExcel(response, list, "乡村振兴轮播图数据");
    }

    /**
     * 获取乡村振兴轮播图详细信息
     */
    @PreAuthorize("@ss.hasPermi('revita:show:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gslSlideShowService.selectGslSlideShowById(id));
    }

    /**
     * 新增乡村振兴轮播图
     */
    @PreAuthorize("@ss.hasPermi('revita:show:add')")
    @Log(title = "乡村振兴轮播图", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GslSlideShow gslSlideShow)
    {
        gslSlideShow.setAsId(getUserId());
        return toAjax(gslSlideShowService.insertGslSlideShow(gslSlideShow));
    }

    /**
     * 修改乡村振兴轮播图
     */
    @PreAuthorize("@ss.hasPermi('revita:show:edit')")
    @Log(title = "乡村振兴轮播图", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GslSlideShow gslSlideShow)
    {
        return toAjax(gslSlideShowService.updateGslSlideShow(gslSlideShow));
    }

    /**
     * 删除乡村振兴轮播图
     */
    @PreAuthorize("@ss.hasPermi('revita:show:remove')")
    @Log(title = "乡村振兴轮播图", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gslSlideShowService.deleteGslSlideShowByIds(ids));
    }
    /**
     * 状态修改
     */
    @Log(title = "消息通知", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody GslSlideShow show)
    {
        return toAjax(gslSlideShowService.updateStatus(show));
    }

}
